home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / filesyst / thsfs.tgz / thsfs.tar / thsfs / divers.c < prev    next >
C/C++ Source or Header  |  1994-10-04  |  2KB  |  116 lines

  1. /*************************************************************
  2.  *                                                           *
  3.  *    ths  Filesystem                  04.10.94      V1.1    *
  4.  *                                                           *
  5.  *    Thomas Scheuermann     ths@ai-lab.fh-furtwangen.de     *
  6.  *                                                           *
  7.  *************************************************************/
  8.  
  9. #include <linux/kernel.h>
  10. #include <linux/module.h>
  11. #include <linux/sched.h>
  12. #include <linux/errno.h>
  13. #include <linux/string.h>
  14. #include <linux/stat.h>
  15. #include <linux/mm.h>
  16. #include <linux/locks.h>
  17. #include <linux/fs.h>
  18. #include <linux/malloc.h>
  19.  
  20. #include <asm/system.h>
  21. #include <asm/segment.h>
  22. #include <asm/bitops.h>
  23.  
  24. #include "ths.h"
  25. #include "ths_i.h"
  26.  
  27. #define UNIX_4_JAHRE 126230400
  28. #define UNIX_JAHR 31536000
  29. #define UNIX_TAG 86400
  30. #define UNIX_STUNDE 3600
  31. #define UNIX_MINUTE 60
  32.  
  33. /*
  34.  * Umrechnung des MSDOS-Zeiteintrags in Unix-Format.
  35.  */
  36.  
  37. long time_ms2u(unsigned short datum, unsigned short zeit)
  38. {
  39.     unsigned long jahr,monat,tag,stunde,minute,sekunde;
  40.     unsigned long unix_zeit;
  41.     unsigned long tab[] = {31,28,31,30,31,30,31,31,30,31,30,31};
  42.     int i;
  43.  
  44.     jahr = (long)(datum >> 9);
  45.     monat = (long)(datum & 0x01e0) >> 5;
  46.     tag = (long)(datum & 0x001f);
  47.     stunde = (long)(zeit >> 11);
  48.     minute = (long)(zeit & 0x07e0) >> 5;
  49.     sekunde = (long)(zeit & 0x001f)*2;
  50.  
  51.     unix_zeit=0;
  52.     jahr += 1980;
  53.     unix_zeit += ((jahr - 1970 + 1)>>2) * UNIX_4_JAHRE - UNIX_JAHR;
  54.     unix_zeit += ((jahr - 1970 + 1) & 0x03) * UNIX_JAHR;
  55.     for(i=1;i<monat;i++)
  56.     {
  57.         unix_zeit += tab[i-1] * UNIX_TAG;
  58.         if(i==2 && ((jahr - 1970 + 1) & 0x03)==3)
  59.             unix_zeit += UNIX_TAG;
  60.     }
  61.     unix_zeit += (tag-1) * UNIX_TAG;
  62.     unix_zeit += stunde * UNIX_STUNDE;
  63.     unix_zeit += minute * UNIX_MINUTE;
  64.     unix_zeit += sekunde;
  65.     return unix_zeit;
  66. }
  67.  
  68.  
  69. /*
  70.  * Vergleich des Namens im Verzeichniseintrag mit
  71.  * dem uebergebenen Namen.
  72.  */
  73.  
  74. int vergleich(struct ths_dir *dir, const char *name, int l)
  75. {
  76.     int j,k,test;
  77.  
  78. /*
  79.  * Namensvergleich
  80.  */
  81.     test=1;
  82.     for(k=0,j=0;k<11;k++)
  83.     {
  84. /*
  85.  * .-Abfrage
  86.  */
  87.         if(k==8 && dir->name[k]!=0x20)
  88.         {
  89.             if(name[j]!='.')
  90.             {
  91.                 test = 0;
  92.                 break;
  93.             }
  94.             j++;
  95.         }
  96.         if(dir->name[k]!=0x20||(j<l))
  97.         {
  98.             if(((unsigned char)name[j]!=dir->name[k])&&(name[j]!='.'))
  99.             {
  100.                 test = 0;
  101.                 break;
  102.             }
  103.             if(dir->name[k]!=0x20)
  104.                 j++;
  105.         }
  106.     }
  107. /*
  108.  * Test auf Volume-Namen
  109.  */
  110.     if(dir->attribut & 0x08)
  111.         test=0;
  112.  
  113.     return test;
  114. }
  115.  
  116.